Skip to content

fix(shader): keep faulting invocations in their wave and mask their later writes - #6416

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
Celegans12:fix/two-lane-wave64-faults
Nov 18, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
Celegans12:fix/two-lane-wave64-faults

Conversation

@Celegans12

@Celegans12 Celegans12 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Stopping a faulting invocation can leave wave ballots unable to converge and stop its healthy partner lane. Eligible non-pixel programs with two lanes per invocation, ballots or shuffles now keep voting with the failed read's zero and mask that lane's later writes, atomics and exports. Existing spanned-wave, barrier and mesh exclusions remain.

Continuing exposed a guarded-SRT reporting regression: the second word of a null pointer replaced the first fault record. Adopt ThatsLeo's first-fault latch from #7922, adapted so masked lanes count as continuing. The existing guarded-pointer runtime oracle stays unchanged, and its host checks require compare-from-zero latches without unconditional overwrites. No spanned-wave policy from #7922 is included.

Masking adds work even without faults. Astro Bot's reported startup delay remains unexplained; no performance claim. The barrier-safe extension and subgroup-specific skip remain separate in #7392 and #6751.

Tested

Based on main b4a8272 (rebased 2026-11-13 as one commit; the only conflict was the cache format, now ShaderDiskCache::FormatVersion 90). On that tip, 61 focused host and NVIDIA tests (fault, guarded-pointer and guarded-load, faulting-wave, BDA span and anchor reads, GPU buffer format, wave decoding, shader memory and shader cache) passed three times with validation 1.4.363 loaded and no VUIDs or skips.

Earlier rounds, on main e6f5730: Windows 11, MinGW-w64 GCC 15.2.0: Release, -DBUILD_TESTING=ON, SPIR-V Tools ON. Before repair, main passes agc_driver_guarded_null_pointer; the merged PR fails 3/3 at address4 instead of0, PC0x24. One diagnostic run confirms the overwrite.

Repaired head 771c8bdae4: 13/13 focused processes pass: host shader-memory; NVIDIA guarded-pointer x3, faulting-wave, GPU-buffer-format, BDA-device and span-reads; the same five GPU tests once on Windows lavapipe. All GPU runs require Vulkan, disable application shader caching and load validation 1.4.363; zero skips, timeouts or validation diagnostics. Lavapipe subgroup8 does not establish paired wave64-on32 behavior. Test registration, conventions and source review pass.

Earlier baseline e2df06e661 plus the faulting-wave fixture fails on main because partner lane37 stays untouched. Not tested: current-head Linux, AMD/Intel hardware, console behavior or titles.

On the merge with main 98346b748c, the wave invocation case initially failed on the hardware-spanning wave path. The follow-up keeps those lanes active but masks writes after a fault, and guards byte loads when the lane continues. Six selected fault, guarded-load, wave-decode and cache tests passed twice on Windows with an NVIDIA RTX 3080 Laptop GPU and Vulkan validation enabled. The updated emitter, BDA read and shader-cache sources also passed Linux C++ syntax and layout-guard compilation. No Linux GPU run was performed.

Checklist

  • Based on current main; the first-fault latch from perf(shader): span single-wave wave64 compute by default after a uniformity check #7922 is adopted with attribution
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA26344 Ghost of Yōtei (PPSA26344) #675
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.62; llvmpipe (Mesa 26.2.4); Windows 11
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6924 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 7085 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 7395 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 8939 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 9457 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 9633 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 9749 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 9790 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 9969 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 10351 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 11551 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 14871 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 15343 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 15555 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 16260 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 16472 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 16571 core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp L44-50
PR 16631 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 16812 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 16814 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 17056 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 18106 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 18107 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 19852 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 20519 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21199 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21240 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21758 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21776 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21924 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21970 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21971 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 21973 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 22359 core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp L341
PR 22424 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 22583 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 22628 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 22690 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 22692 core/shader/recompiler/ShaderDiskCache.hpp L16
PR 22703 core/shader/recompiler/ShaderDiskCache.hpp L16

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5925 core/shader/recompiler/ShaderDiskCache.hpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6280 core/shader/recompiler/ShaderDiskCache.hpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvBdaFault.cpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvBdaFault.cpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp
PR 9852 core/shader/recompiler/ShaderDiskCache.hpp
PR 10359 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10652 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 10867 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 12324 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12944 core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp
PR 14032 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14853 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14944 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 15548 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 16952 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 17611 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.hpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
PR 20030 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20111 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20187 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp

@Pipodi

Pipodi commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@Celegans12 a data point from Ghost of Yōtei (PPSA26344): RTX 4090, driver 617.42, Windows 11. This PR on main 0dab493 + #5815 #5781 #6227 #5405 #6402 #6174, with APS5_SPANNED_WAVE=1 (#5405) and a cold shader cache (our run163).

In our base, this PR conflicted in SpirvEmitter.cpp with a local change that kept spanned programs out of the BDA stop. I took this PR's version and counted spannedWave as a wave operation (waveOperations = ... || state.spannedWave), so spanned programs take the write-masking path.

It still loses the device, at ~1,460 s (frame ~817):

  • nvlddmkm event 153, a TDR (TdrDelay 10 s);
  • vkQueueSubmit recorder: Vulkan result -4;
  • 42 device faults with an unknown instruction pointer at 0x309250c60-0x3092511c0.

That's the same signature as our earlier spanned runs without this PR.

The non-spanned build of 0x80001e5f00 (839,036 words) dispatched fine. The spanned pipeline (838,306 words) was created about 5 minutes before the loss, but the log has no dispatch line for it. After it came several minutes of cold compiles of new 0x801d* programs, and the loss hit while 0x801d29eb00 was being created. So I can't tell whether that program or another spanned one hung. With spanned waves off, the same base runs well past that point.

If you have a suspect, I can rerun with more logging.

@Celegans12

Copy link
Copy Markdown
Contributor Author

A cost I measured tonight that reviewers should know about: on NVIDIA, the write mask roughly doubles pipeline compile time for PPSA26344's giant two-lane compute programs.

Compiled side by side on the same machine, compute 0x801cdd2700 (about 1.75M SPIR-V words) takes 700 s with the earlier "reads continue, nothing masked" version and 1,411 s with this PR. The module is only about 0.5% bigger: roughly 90 more branches and about 550 more stores and loads of the per-lane faulted flag. So the extra time looks like NVIDIA's compiler handling a flag that stays live across the whole program, not the extra code itself.

For now our game branch keeps the older version, so our precompiles don't take twice as long. I'll look at making the mask cheaper, for example only guarding writes that a fault can reach, or keeping the flag in a form the compiler handles better, and post numbers here. If anyone has a preferred shape for this, I'm happy to hear it before I start.

Details
  • Windows 11, RTX 3080 Laptop GPU (driver 610.62). agc_shader_replay --pipeline-only into an empty VkPipelineCache and an empty NVIDIA store, both builds compiling concurrently.
  • Request: PPSA26344 compute 0x801cdd2700. 1,751,533 SPIR-V words without the mask, 1,760,989 with it.
  • A smaller program (0x806eddec00, 589k words) doesn't take the flag path and compiles in 18 s either way, with an identical pipeline fingerprint.

@Dextroid17

Copy link
Copy Markdown
Contributor

Tested on Linux with lavapipe, the CI device: llvmpipe (Mesa 26.2.4, LLVM 23.1.1), CachyOS, GCC 16.2.1, CMake 4.4.3, default build type, full build with BUILD_TESTING=ON. Each run used a clean environment (env -i with HOME, PATH, VK_ICD_FILENAMES and GALLIUM_OVERRIDE_CPU_CAPS=avx).

This PR (b5a0c1ff7 merged into main 44df21632, no conflicts):

  • agc_driver_faulting_wave_invocation and agc_driver_gpu_buffer_format: pass, 3 runs out of 3.
  • With this PR's 5 source files reverted to main and its tests kept, both still pass, 3 runs out of 3. So on lavapipe the new test passes without the fix.

The reason, from the code: lavapipe reports 8-wide subgroups (minSubgroupSize = maxSubgroupSize = 8). Two lanes per invocation only happens when the host subgroup is 32 (SpirvEmitter.cpp:265, laneCount is 2 only when hostSubgroupSize == 32u). The write mask itself is still enabled there, since the execz branch makes the program need ballots. But the failures the test checks (the execz loop that never ends, and the partner lane 37 stopping with lane 5) need two lanes per invocation. So the description's "on main it fails" holds on 32-wide subgroups but not on lavapipe, and CI would stay green if the fix regressed. Wave32Subgroup.cpp:73 skips with a reason when the subgroup does not fit. Something similar here, for example:

if (device->Target().subgroupSize != 32u) {
    std::printf("skipped, the device runs wave64 programs on %u-wide subgroups\n", device->Target().subgroupSize);
    return VulkanTestSkipped;
}

would make lavapipe report a device-limited skip (tools/check_skips.py accepts reasons that mention subgroups) instead of a pass. Only a suggestion; whether a 64-wide device should run it is your call.

This may be useful for the mask rework you mention: on lavapipe the test passes even with the fix reverted, so it can't show whether a cheaper mask still handles the two-lane cases. That can only be checked on a 32-wide device, such as your RTX 3080 Laptop GPU.

Merged together with #6402 (on main 44df21632, no conflicts): full ctest: 2 of 1269 fail, 57 skipped (the same skips as main). The two failures are not from either PR:

  • agc_driver_mesh_index_cache segfaults on main too (and 5 runs out of 5 on the merge).
  • agc_frame_dump_io (from fix(agc): disable optional BMP dumps after host I/O failures #5800) also fails on plain main, in 13 of 200 runs on an idle machine: closed pipe pixel write was accepted. Reading the test, its 128×128×4 = 65,536 pixel bytes are exactly Linux's default pipe buffer, so if the reader drains the 54-byte header before the pixel write starts, the empty pipe takes the whole write and it succeeds before the reader closes. Not measured beyond that.

Apart from those, the failed and skipped lists match main's full run.

Not tested: NVIDIA, AMD, Intel, PPSA26344.

AI-assisted: yes

@Amoenus

Amoenus commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Barrier-program follow-up: #6689.

I reproduced later guest writes after an unmapped BDA read plus s_barrier on otherwise unchanged main. Main plus your current head b5a0c1ff79eb52bd52fea0ba6d0434e072190b99 still reproduces it in 5/5 runs on each of an RTX 5080 and AMD Radeon iGPU (Windows). bdaFaultMasksWrites currently requires bdaStopsInvocations, which excludes the barrier programs.

Proposed follow-up reuses your per-lane mask, keeps the invocations at their barriers, and carries the checked BDA helper's fault result back to the correct lane half. All-fault and mixed valid/faulting lane tests pass 5/5 per GPU. The full Windows build and focused checks passed, but broader regression/static-analysis gates remain incomplete; the current checkpoint and remaining checks are recorded in #6689. This prototype is deferred while we pivot to PR maintenance.

Proposed ordering is #6416 first, then this compute follow-up. If you prefer to incorporate it here, the focused commit is available to take. No competing upstream PR is open.

AI-assisted: yes.

@MarcZX10

Copy link
Copy Markdown
Contributor

While preparing the barrier follow-up, I checked the narrow-subgroup case raised in the review. The current agc_driver_faulting_wave_invocation passes on llvmpipe with subgroup size 8, and the review reports it also passes with the implementation reverted there; that device does not exercise the two-lane EXEC case the test is meant to cover. A device-limitation skip when subgroup size is not 32 would make that coverage status explicit. The follow-up mixed-lane control had the same assumption: on subgroup 8 it reported 63 mismatches. I have a local test-only guard for that mixed control on subgroup != 32; the two focused CTests then pass on llvmpipe (with the host CPU capability guard temporarily bypassed). The 32-lane mixed case still needs a suitable device, as your Windows NVIDIA/AMD runs provide.

@MarcZX10

Copy link
Copy Markdown
Contributor

I opened stacked follow-up #6751 for the test-only subgroup guard discussed here. The agc_driver_faulting_wave_invocation case now reports a device-limited skip unless the host subgroup is exactly 32 lanes, because narrower/wider subgroups do not exercise the two-lanes-per-invocation wave64 case. #6751 carries your current PR commits unchanged and depends on #6416; Linux target build and conventions passed locally. The focused CTest cannot reach Vulkan on my Xeon because it lacks the required CPU instruction sets.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 16, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 17, 2026
@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main (authorship unchanged). One conflict in SpirvEmitter.cpp: main added !state.spannedWave to the bdaStopsInvocations condition while this PR adds the bdaFaultMasksWrites computation after it — the merged version keeps main's condition and layers your fault-masking computation.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/6416
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 48482f629.

@oneandonlydean

oneandonlydean commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks. Main has moved under this PR: since bd6ed97, bdaStopsInvocations is false in spanned waves (a single-wave wave64 compute program on a 32-lane host with full subgroups, 80e3d90/7a6cc717863). Because bdaFaultMasksWrites requires bdaStopsInvocations and StopBdaInvocationIf returns early without it, a straight rebase turns the masking off for every single-wave program, including the test here, which I'd expect to fail on an NVIDIA or full-subgroup AMD device after the rebase. Since masking keeps invocations running, could it apply in spanned waves too (record the fault in StopBdaInvocationIf before the !bdaStopsInvocations return, and gate masking on the fault kinds rather than on stopping), with the test covering a spanned single wave and a two-wave workgroup? Pipodi still sees spanned wave64 dispatches hang in PPSA26344, so a run of the rebased head there would tell us whether this is the remaining cause.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@oneandonlydean

oneandonlydean commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Correction to my earlier note: spanned waves are opt-in on main (APS5_SPANNED_WAVE, VulkanDevice.cpp:1784), so by default this PR's test runs the two-lane path with masking on and passes, and it fails with masking forced off, so the rebase onto main is fine as is. I pushed it to this branch (9c76817) and started a full CI run. The gap I described applies only with APS5_SPANNED_WAVE=1: there bdaStopsInvocations is false, masking is off, and the test fails with "lane 5 stored after its read faulted". Not a blocker for this PR; as a follow-up, could the masking also cover spanned waves (record the fault before the !bdaStopsInvocations return) and the test run once with APS5_SPANNED_WAVE=1? That may be what still hangs PPSA26344's spanned runs.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apple GPU / MoltenVK run. Apple's subgroup size is exactly 32, the case agc_driver_faulting_wave_invocation needs (see #6751): red without the fix, green with it, and no other change.

Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head 9c76817, PR diff applied cleanly. Driver: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), subgroup=32.

Tested: the tree is main a373e85 + mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plain main (it doesn't build on macOS yet). Base on that tree: 40 ^agc failures, the same known failures in every run below unless noted.

  • agc_driver_faulting_wave_invocation with the PR: passes 3 of 3.
  • The test alone on the base tree: fails with lane 0 left the EXEC loop after 100 passes, expected 4 (the loop stops at 100).
  • Full ^agc suite with the PR: 40 of 728 fail, the same 40 as the base.

About the spanned-wave gap @oneandonlydean described: it can't occur on MoltenVK today. With APS5_SPANNED_WAVE=1 the driver logs spans two full 32-lane subgroups: 0, because MoltenVK doesn't give full compute subgroups, so wave64 always takes the two-lane path here and the masking stays on.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2)

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@Celegans12

Copy link
Copy Markdown
Contributor Author

@oneandonlydean, thanks for doing the rebase and for sorting out the spanned-wave question. Yes, I'll take the spanned-wave masking as a follow-up PR once this one is in. The plan is what you describe: record the fault in StopBdaInvocationIf before the !bdaStopsInvocations return, gate the masking on the fault kinds rather than on stopping, and run the test once more with APS5_SPANNED_WAVE=1, for a single spanned wave and for a two-wave workgroup. @jotitadev's run shows the gap can't happen on MoltenVK, so the follow-up is about NVIDIA and full-subgroup AMD.

About Yōtei: our runs do use APS5_SPANNED_WAVE=1, but they don't carry this PR's masking yet, because of the compile-time cost I mentioned earlier. So I can't tell yet whether this is what still hangs the spanned runs. I'll try it in a game run with the follow-up once the machine is free.

hritikutekar added a commit to hritikutekar/AnyPS5 that referenced this pull request Oct 20, 2026
…x for named wave-operation programs (boykopovar#6416 masks elsewhere)
@Celegans12
Celegans12 force-pushed the fix/two-lane-wave64-faults branch from 22e2f3a to 9588d31 Compare November 14, 2026 20:44
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 14, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 16, 2026
@BunnyFl

BunnyFl commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@Celegans12, cc @oneandonlydean (your 10-27 question about late level starts in ASTRO BOT): we ran the cold-start comparison on AMD and Windows, and with this PR the level did not start late.

Setup. ASTRO BOT (PPSA21567, 01.019.000), AMD Radeon RX 9070 XT, AMD proprietary driver 26.11.1, Windows 11 build 26300, Ryzen 7 5800X3D. Two layouts from one clone: plain main 00fbc718c8, and the same main with this PR's head ab3e21c97c merged in locally (the merge built cleanly then; the PR conflicts with current main now). Each launch went straight into the Crash Site hub with -lvl hub_crashsite, no save and no input, and ran for 180 s. The first launch of each layout is listed as "warm-up"; then three launches per side, alternating main and PR. The last frame dump of runs 1 and 3 on each side shows the hub with Astro standing in it, the same picture on both sides (the other runs' frames were not looked at).

Level start (the [m:ss] stamp of the title's own StartLevel hub_crashsite line):

warm-up run 1 run 2 run 3
main 00fbc718c8 0:22 0:19 0:24 0:19
main + this PR 0:21 0:19 0:19 0:19

The texture-budget step. The [gpu] sampled texture cache budget ... line is logged before StartLevel in all 8 runs, on both sides (3 to 5 such lines per run; the first one at the same point of each log, lines 542-544). So on this machine nothing is missing from this PR's runs before the level, and no run ended with a FATAL line.

Limits.

  • One machine and one GPU; four launches per side are observations, not a reproduction.
  • These launches skip the title screen and menus (-lvl). The title/menu stretch that grew by about 12 s in your RTX 4090 runs (comment) is not covered as you ran it. If your gate starts from the title screen, say how it gets to the level (presses and timing) and we can run that path the same way.
  • The StartLevel stamps have one-second resolution. The budget line carries no timestamp of its own; its place above is its line position in each log, not a time.

AI-assisted: yes (Claude Code)

@BunnyFl

BunnyFl commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@Celegans12, cc @oneandonlydean, one note on our ASTRO BOT level-start runs (AMD Radeon RX 9070 XT, AMD proprietary driver 26.11.1, Windows 11 build 26300): their base main 00fbc718c8 already has #16053, the change #20845 reverts. Both sides of that comparison had it, main and main + this PR alike. Your 10-27 runs were on d13b3d7c55, which does not have it. The level-start times we posted were measured on a different base than yours. We have not rerun ASTRO BOT with #20845 merged.

AI-assisted: yes (Claude Code)

@BunnyFl

BunnyFl commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@oneandonlydean, cc @Celegans12: a repeat of your 10-27 ASTRO BOT check as you described it (unprofiled and draw-profiler runs, time to the level, the texture-budget line), this time on a base without #16053. On AMD / Windows the PR started the level on time in every run, and the texture-budget line was there in every PR run.

Setup. ASTRO BOT (PPSA21567, 01.019.000), AMD Radeon RX 9070 XT, AMD proprietary driver 26.11.1 (the summary line names it LLPC), Windows 11 build 26300, Ryzen 7 5800X3D. This PR's head ab3e21c97c against its own merge base with main, 5cc140af09, which has neither #16053 nor #18387; the two builds differ by the PR's two commits. We did not use your d13b3d7c55: git rev-list --count d13b3d7c55..ab3e21c97c is 21,343, and merging this head onto it would bring in all of those later main commits. Each launch went straight into the Crash Site hub with -lvl hub_crashsite; the 5cc140af09 control build reaches the level at 0:19, close to the 22.8 s in your comment. The route your gate takes is not described there, and this is the closest match we could make. APS5_LOG_TIMESTAMPS=1 throughout, 120 s per launch, alternating main and PR, one cold launch of each first (not counted).

runs level start, game's [m:ss] stamp last timestamped log line before StartLevel hub_crashsite first sampled texture cache budget line
main 5cc140af09, unprofiled 4 0:19 in all 4 21.7-22.0 s 1.7-2.1 s, before the level in all 4
this PR, unprofiled 4 0:19 in all 4 21.7-22.0 s 1.7-2.1 s, before the level in all 4
main, APS5_PROFILE_DRAW=1 2 0:19, 0:19 21.8, 21.9 s 1.7-2.1 s
this PR, APS5_PROFILE_DRAW=1 2 0:19, 0:19 21.6, 21.7 s 1.7-2.1 s

The game's StartLevel and the driver's budget line carry no timestamp of their own; the times above are the timestamped log lines just before them (the next timestamped line comes about 4 s later). No run had a FATAL line. The two cold launches started the level at 1:27 (main, compiling the shader cache) and 0:21 (PR, reusing it); the shader cache is shared between the two builds.

So on this machine neither symptom shows: no late level start in 6 of 6 PR runs, and the budget line is present in all 7 PR runs including the cold one.

Limits.

  • One machine and GPU vendor; your late starts were on an RTX 4090 under Linux, which we cannot test.
  • The frame dumps cover only the first 20 s (4 per launch); the last one, at about 20 s, shows the Crash Site fly-in in 9 of the 12 warm launches and is still dark in 3 (two main, one PR).
  • Not the same base as your runs, for the reason above.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

Changes are required before merge: please confirm the invocation fault mask is correct for memory writes that happen inside emitted helper functions.

What I ran

Reviewed head ab3e21c97c54ce34cff2611cc5dd33f3bb02fb3a using the prepared diff and the pinned repo_read.py reader. No build or tests were run by me; test results in the PR description are author reported.

Results

Check Result Note
Diff and targeted source review passed Emitter, fault, read and test paths inspected
Build and tests not run No commands executed

Findings

Blocking

None verified.

Non-blocking

  • The new guard in EmitUnlessInvocationFaulted applies only to instructions emitted directly from the structured block. Please verify that writes performed by helper functions called from a later instruction are also suppressed after a lane faults. I did not trace all helper call paths, so this is a question for follow-up rather than a verified defect. The relevant dispatch is at core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp:837.

Not verified

  • ShaderMemory.cpp was read through the pinned reader around the changed guarded-pointer checks; the rest of that large file was not read. All other changed source files listed as included in the manifest were read in targeted sections, along with the added FaultingWaveInvocation.cpp.
  • repo_read.py reports ShaderMemory.cpp as excluded from the review folder for size; the remaining changed files were included. files.json was unavailable as a review-folder file, so exclusions are reported from the manifest and reader listing.
  • Build, current-head tests, CI, console behavior, and the complete set of helper-function write paths were not verified. Test outcomes in description.md are author reported.

To get this to a good state

Nothing is required. Optional: confirm and, if needed, test that helper-function writes are masked after the faulting read.

Keep FormatVersion 90 (main is at 88) and keep both main's NaN region
emitters and this branch's write masking helpers in SpirvFlowEmitter.cpp.
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Celegans12 I merged main into the branch (e16be77) to clear the conflicts. ShaderDiskCache.hpp keeps FormatVersion 90 (main is at 88, and the other open shader PRs now use 101 and 103). In SpirvFlowEmitter.cpp main's new NaN region emitters and your WritesGuestState and EmitUnlessInvocationFaulted helpers landed in the same place; I kept both blocks whole. agc_driver_faulting_wave_invocation and the agc_shader_memory tests pass on Linux at the merge head. Please pull before your next push.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed needs rebase Conflicts with main, rebase needed labels Nov 17, 2026
@domx4q

domx4q commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Ran the faulting-wave case and the neighbouring guarded-pointer and BDA tests at the current head on Linux, which the description lists as not tested, with NVIDIA's proprietary driver and the Khronos validation layer.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head e16be774a4 merged onto main 1ccc399b17 with --no-ff, clean merge. Main baseline is a Release build of 1ccc399b17 on the same machine.

WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 ANYPS5_REQUIRE_DISPLAY=1 \
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^(agc_shader_memory|agc_driver_guarded_.*|agc_driver_faulting_wave_invocation.*|agc_driver_gpu_buffer_format|agc_driver_bda_device|agc_driver_bda_span_reads)$' -V
main 1ccc399b17 this PR
Result 6/6 passed 7/7 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 5 6
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

agc_driver_faulting_wave_invocation is new in this PR and does not exist on main; it passes (faulting wave invocation tests passed). agc_driver_guarded_null_pointer, agc_driver_guarded_direct_root, agc_driver_gpu_buffer_format, agc_driver_bda_device, agc_driver_bda_span_reads and agc_shader_memory pass on both sides. Every device selection picked the RTX 4090.

Negative control: this PR's build with main's core/shader/recompiler sources (the eight files this PR changes there) fails agc_driver_faulting_wave_invocation deterministically (2 of 2 runs) with AGC graphics: faulting wave invocation: lane 5 stored after its read faulted, and logs no VUID-.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.